﻿using Stock.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Stock.Dao
{
      public class XueqiuDao : BaseDao
      {
            private static string TableName = "T_STOCK_LOG";

            /// <summary>
            /// 写入实时报价
            /// </summary>
            /// <param name="stockInfo"></param>
            /// <param name="code"></param>
            /// <param name="name"></param>
            /// <returns></returns>
            public static bool Insert(StockInfo_Xueqiu stockInfo, string code, string name)
            {
                  foreach (var item in stockInfo.data)
                  {
                        string sql = string.Format("INSERT INTO {0} ([CODE],[NAME],[HIGH],[LOW],[OPEN],[CLOSE],[PRECENT],[VOLUME],[AMOUNT],[TURNOVER_RATE]," +
                              "[AVG_PRICE],[CHG],[LAST_CLOSE],[GET_DATE]) ", TableName);
                        sql += string.Format(" VALUES ({0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12});", code, name, item.high, item.low, item.open, item.current,
                              item.percent, item.volume, item.amount, item.turnover_rate, item.avg_price, item.chg, item.last_close, DateTime.Now);
                        BaseDao.Insert(sql);
                  }

                  return true;
            }



      }
}
